package com.caipin.controller;

/**
 * @Author: zhunian0322@163.com
 * @DateTime: 2021-09-30 9:25
 * @Description: TODO
 */
@RestController
public class JZHGateManagementController {
    private static final Logger log = LoggerFactory.getLogger(com.caipin.controller.JZHGateManagementController.class);

    @Autowired
    private JZHGateManagementService jzhGateManagementService;

    @PostMapping({"/syface/{deviceId}"})
    public Object comparisonResults(@PathVariable("deviceId") String deviceId, @RequestBody ComparisonResults comparisonResults) {
        this.jzhGateManagementService.saveComparisonResults(deviceId, comparisonResults);
        Map<String, Object> map = new HashMap<>();
        map.put("ret", Integer.valueOf(0));
        map.put("desc", "Success");
        return map;
    }

    @PostMapping({"/syattribute/{deviceId}"})
    public Object syattribute(@PathVariable("deviceId") String deviceId, @RequestBody TemperatureReport temperatureReport) {
        this.jzhGateManagementService.saveTemperatureReport(deviceId, temperatureReport);
        Map<String, Object> map = new HashMap<>();
        map.put("ret", Integer.valueOf(0));
        map.put("desc", "Success");
        return map;
    }

    @GetMapping({"/syrecord/{deviceId}"})
    public Object getFaceDataBase(@PathVariable("deviceId") Integer deviceId, @RequestParam("lastQueryTime") Long lastQueryTime, HttpServletRequest request) {
        log.info("getFaceDataBase deviceId " + deviceId);
        log.info("getFaceDataBase lastQueryTime " + lastQueryTime);
        FaceDataBase.ServiceResponseBean serviceResponseBean = this.jzhGateManagementService.getServiceResponseBean(lastQueryTime, request.getServerName());
        FaceDataBase faceDataBase = new FaceDataBase();
        faceDataBase.setServiceResponse(serviceResponseBean);
        return faceDataBase;
    }
}

